/**
 ***********************************************************************************************************
 * 
 ***********************************************************************************************************
 * @file RBD3D11HardwareBufferManager.h
 ***********************************************************************************************************/

#pragma once

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBD3D11HardwareBufferManager.h)
#endif

/***********************************************************************************************************
 * Includes
 ***********************************************************************************************************/
#include <RBMain/RBHardwareBufferManager.h>
#include <RBMain/RBPixelFormat.h>

/***********************************************************************************************************
 * Forward declarations
 ***********************************************************************************************************/
struct ID3D11Device;
struct ID3D11ShaderResourceView;
struct ID3D11Buffer;
struct D3D11_BUFFER_DESC;

/***********************************************************************************************************
 * Classes
 ***********************************************************************************************************/

class RBD3D11HardwareBufferManager : public RBHardwareBufferManager
{
    RBDeclareRTTI(RBD3D11HardwareBufferManager, RBHardwareBufferManager)
public:
				                    RBD3D11HardwareBufferManager    (ID3D11Device* pDevice);
    virtual                        ~RBD3D11HardwareBufferManager    ();

    static bool                     create_texture                  (ID3D11Device* dev, const char* filename, ID3D11ShaderResourceView** ppRV);
    static bool                     create_buffer                   (ID3D11Device* dev, ID3D11Buffer** ppBuffer, D3D11_BUFFER_DESC* BufferDesc, void* data);

    RBVertexBuffer*                 create_vb_from_d3d              (ID3D11Buffer* d3d_vb);
    RBIndexBuffer*                  create_ib_from_d3d              (ID3D11Buffer* d3d_vb);

    virtual RBVertexBuffer*         CreateVertexBuffer              (uint32 uiUsage, uint32 uiVertexSize, uint32 uiVertexCount, const void* pInitData);
    virtual RBIndexBuffer*          CreateIndexBuffer               (uint32 uiUsage, RBIndexBufferType::EType eIndexType, uint32 uiIndexCount, const void* pInitData);
    virtual RBVertexDeclaration*    CreateVertexDeclaration         (RBVertexElement* pElements, uint32 uiElementCount, RBEffectPass* pEffectPass);
    virtual RBTexture*              CreateTexture                   (const char* pcFilename, uint32 uiUsage = rb_hw_buffer_usage::HBU_DEFAULT);
    virtual RBTexture*              CreateTexture                   (uint32 uiUsage, uint32 uiWidth, uint32 uiHeight, 
                                                                     RBPixelFormat eFormat, RBTextureType::EType eType,
                                                                     uint32 uiMips = 0, uint32 uiDepth = 0, uint32 eMemPool = 1);
    virtual RBShaderResourceView*   CreateShaderResourceView        (RBTexture* pBuffer, RBPixelFormat eFormat);
    virtual RBRenderTargetView*     CreateRenderTargetView          (RBTexture* pBuffer, RBPixelFormat eFormat);
    virtual RBDepthStencilView*     CreateDepthStencilView          (RBTexture* pBuffer, RBPixelFormat eFormat);
    virtual RBShaderSamplerState*   CreateSamplerState              (const RBTextureSampler& sampler);
    virtual RBRasterizerState*      CreateRasterizerState           (const RBMaterial& material);
    virtual RBBlendState*           CreateBlendState                (const RBMaterial& material, uint32 colorWrites);
    virtual RBDepthStencilState*    CreateDepthStencilState         (const RBMaterial& material);

    virtual RBTexture*              CreateRenderTarget              (uint32 uiUsage, uint32 uiWidth, uint32 uiHeight, RBPixelFormat eFormat, 
                                                                     uint32 uiMSAA);

    void                            OnReset                         (bool bBeforeReset);

    virtual void                    ReleaseNative               (RBHardwareBuffer* pVB) ;

private:

    ID3D11Device*                   m_pDevice;
};


/***********************************************************************************************************/
